package com.gmall.user.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gmall.model.user.UserAddress;
import com.gmall.user.mapper.UserAddressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@SuppressWarnings("all")
public class UserAddressService{

    @Autowired
    private UserAddressMapper userAddressMapper;

    /**
     * 查询用户地址列表
     * @param userId
     * @return
     */
    public List<UserAddress> findUserAddressListByUserId(Long userId) {
        //sql select *from user_address where user_id=?
        //封装条件
        QueryWrapper<UserAddress> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(UserAddress::getUserId,userId);
        //执行查询
        return userAddressMapper.selectList(queryWrapper);
    }
}
